<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>FLDCMS后台管理系统</title>
<meta name="keywords" content="FLDCMS，FLDCMS后台管理系统">
<meta name="description" content="FLDCMS，是一款由FLD开发的轻量级扁平化网站后台模板，适合中小型CMS后台系统。">
{include file="public/header" /}
<style>
	img[nc_type="flex"]{cursor:pointer;}
</style>
</head>
<body>
<article class="page-container">
	<form action="{:url('cate/edit')}" method="post" class="form form-horizontal" id="form-add">
		<input type="hidden" name="form_submit" value="ok"/>
		<input type="hidden" name="id" id="id" value="{$vo.id}"/>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>分类名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$vo.cate_name}" placeholder="请填写分类名称" id="cate_name" name="cate_name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">关键字：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$vo.cate_keyword}" placeholder="请填写关键字，若不填写，则默认分类名称" id="cate_keyword" name="cate_keyword">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">描述：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="cate_description" cols="5" rows="50" class="textarea radius" placeholder="请填写描述，若不填写，则默认分类名称">{$vo.cate_description}</textarea>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">排序：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$vo.sort}" placeholder="请填写排序" id="sort" name="sort">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
			</div>
		</div>
	</form>
</article>
{include file="public/footer" /}
<script type="text/javascript">
$(function(){
	$("#form-add").validate({
		rules:{
			cate_name:{
				required:true,
				maxlength:20,
				remote: {
				    url: "{:url('cate/check_name_ajax')}",    //后台处理程序
				    type: "post",               //数据发送方式
				    dataType: "json",           //接受数据格式   
				    data: {                     //要传递的数据
				    	cate_name: function() {
				            return $("#cate_name").val();
				        },
				        id: function(){
				        	return $("#id").val();
				        }
				    }
				}
			},
			sort:{
				number:true,
			},
		},
		messages: {
			cate_name:{
				required:'分类名不能为空',
				maxlength:'分类名不能大于20个字符',
				remote: '分类名已经存在',
			},
			sort:{
				number:'排序必须为数字',
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
                dataType:"json",
                success:function(data){
                   if(data.error == 0){
                	   	layer.msg(data.msg, {icon: 1,time: 1000}, function(){
                	   		var index = parent.layer.getFrameIndex(window.name);
                			parent.location.reload();
               				parent.layer.close(index);
                		});
                   }else{
                	   layer.msg(data.msg,{icon:2,time:1000});
                   }
                }
            });
		}
	});
});

</script>
</body>
</html>